/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataAcces;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author bazan
 */
public class Conexion {

    private static Connection cnx;

    public Conexion() {
    }

    public static Connection ObtenerConeccion() throws SQLException 
    {
        String url = "jdbc:sqlserver://localhost:1433;databaseName=BDACCELCOM";
        String usuario = "sa";
        String password = "123";

        if (cnx == null)//si cnx es igual al vacio es decir no se creo una conexion
        {
            try {
                
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                cnx = DriverManager.getConnection(url, usuario, password);

            } catch (ClassNotFoundException ex) {
                
                System.out.println(ex.getMessage());
            }

        }
        return cnx;

    }
}
